import { ElMessage } from 'element-plus'

class Util {
  /*
   提示公用
   @params msg:提示字段
   @params type:类型 success/warning/info/error
   @params time: 消失时间
   */
  alert(msg, type, time) {
    if (!type) {
      type = "error";
    }
    if (!time) {
      time = 2000;
    }
    ElMessage({
      showClose: true,
      type: type,
      message: msg,
      duration: time,
      customClass: "message-box",
      zIndex: 999999999999,
    });
  };
  //清除全局的loading
  clearLoading() {
    var loadingNodeList = document.getElementsByClassName("api-common-loading");
    if (loadingNodeList) {
      for (let i = 0; i < loadingNodeList.length; i++) {
        loadingNodeList[i].parentNode.removeChild(loadingNodeList[i]);
      }
    }
  }
}

export default new Util();
